package cn.edu.nwsuaf.teachercenter.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.nwsuaf.teachercenter.pojo.ExamPaperInfo;
import cn.edu.nwsuaf.teachercenter.service.ExamPaperService;

@Controller
@RequestMapping(value="/exam")
public class ExamPaperInfoController {
	@Resource(name="examPaperService")
	private ExamPaperService examPaperService;
	
	@ResponseBody
	@RequestMapping(value="/addExamPaperInfo",method=RequestMethod.POST)
	public String addExamPaperInfo(@ModelAttribute ExamPaperInfo examPaperInfo){
		return examPaperService.addExamPaper(examPaperInfo);
	}
	
	@RequestMapping(value="/loadExamPaperInfo/{teacherNo}")
	public String loadPaperInfo(@PathVariable("teacherNo")String teacherNo, @RequestParam(value="p", required=false)String p,ModelMap modelMap){
		examPaperService.loadExamPaper(teacherNo, p, modelMap);
		return "exam-paper-info-list";
	}
}
